<?php
namespace app\store\controller\parent;


use app\store\controller\Base;
use think\Db;
header("Content-type:text/html;charset=utf-8");

class Sign extends Base
{
    public function detail(){

        if(request()->isAjax()){

            $openid = Db::name('parent')->where('id',$this->uid)->value('openid');
            // 获取学生信息

            $stu_id = Db::name('parent_bind_student')->where('parent_openid',$openid)->value('stu_id');
            $stu = Db::name('student')->where('stu_id',$stu_id)->find();

            //通过sort_id 到文章表找相应类别的文章
            $page = input('page') ? input('page') : 1;
            $limit = input('limit') ? input('limit') : 5;


            //  签到详情
            $res = Db::name('student_sign')
                ->where('stu_no',$stu['stu_no'])
                ->page($page,$limit)
                ->select();

            foreach ($res as $index => $re) {
                $res[$index]['time'] =   date('Y-m-d  H:m:s',$re['time']);
            }

            return json(['code' => 1, 'msg' => 'ok', 'count' => count($res),  'data' => $res]);
        }

        $this->assign('shop_id',$this->shop_id);
        return $this->fetch();
    }
}
